package com.yidu.logisticssystem.controller;

import com.yidu.logisticssystem.entity.LogisticsDetailtype;
import com.yidu.logisticssystem.service.LogisticsDetailtypeService;
import com.yidu.logisticssystem.utils.BaseMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 状态详细类型表(LogisticsDetailtype)表控制层
 *
 * @author makejava
 * @since 2021-03-08 16:46:48
 */
@Api(tags = "状态明细接口")
@RestController
@RequestMapping("logisticsDetailtype")
public class LogisticsDetailtypeController {
    /**
     * 服务对象
     */
    @Resource
    private LogisticsDetailtypeService logisticsDetailtypeService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "根据id查询状态明细",notes = "返回状态明细")
    @GetMapping("selectOne")
    public BaseMessage selectOne(Integer id) {
        return BaseMessage.succes(logisticsDetailtypeService.queryById(id));
    }


    /**
     *  增加或修改
     * @param logisticsDetailtype
     * @return 改变行数
     */
    @ApiOperation(value = "增加或修改状态明细",notes = "返回改变行数")
    @GetMapping("addOrUpdate")
    public BaseMessage addOrUpdate(LogisticsDetailtype logisticsDetailtype){
        int rows=0;
        if(logisticsDetailtype.getDetailtypeId()==null){
            rows=logisticsDetailtypeService.insert(logisticsDetailtype);
        }else {
            rows=logisticsDetailtypeService.update(logisticsDetailtype);
        }
        return rows>0?BaseMessage.succes():BaseMessage.fail();
    }

}
